<?php
class PayApp extends CommonApp {
   
    public function indexAct(){
    	$ids = $_GET['ids'];//所购买的商品id
        $number = $_GET['total'];//所购买的商品数目
        $ids = explode(",", $_GET['ids']);
        $number = explode(",", $_GET['total']);
        $member = $_SESSION['member'];
        foreach ($ids as $key => &$value) {
            if(!My::is_id($value)) $this->ajaxReturn(404,'购物车id出错！');
            $result[] = DB('car')->where(" id ='{$value}' AND member_id = '{$member['id']}'")->find();
            $result[$key]['number'] = $number[$key];
        }
        $address_id = DB('address')->where("parent = '{$member['id']}' AND hot = '1' OR parent = '{$member['id']}'")->clear()->getField('id');
        $this->assign('address_id',$address_id);
        $this->assign('result',$result);
		$this->display();
    }

    //核对购物的物品
    public function checkAct(){
    	if(!$_POST)
    		$this->ajaxReturn(300,'购物车参数有误！');
    	if(!$_SESSION['member'])
    		$this->ajaxReturn(300,'请先登陆！');
    	$ids = explode(",", $_POST['ids']);
    	$str = '';
    	// foreach ($ids as $key => &$value) {
     //        if(!My::is_id($value)) $this->ajaxReturn(300,'购物车id出错！');
    	// 	$result[] = DB('car')->where(" id ='{$value}' AND member_id = '{$_SESSION['member']['id']}'")->find();
    	// 	if(strtotime($result[$key]['rate'])<strtotime(date("Y-m-d H:i:s")))
    	// 		$str .= $result[$key]['goodsname']."，已过活动时间，请取消购买！<br>";
    	// }
    	if(!empty($str))
    		$this->ajaxReturn(201,$str);
    	else
    		$this->ajaxReturn(200,'购买');
    }
   
}